{extend name="Public:base" /}

<!-- 标题 -->
{block name="title"}<title>编辑栏目</title>{/block}
<!-- 面包屑导航 -->
{block name="navigation"}
<section class="content-header">
	<h1>编辑栏目<small></small></h1>
	<ol class="breadcrumb">
		<li><a href="{:url('index/index')}"><i class="fa fa-dashboard"></i> 主页</a></li>
		<li class="active">栏目管理</li>
	</ol>
</section>
{/block} 

<!-- 内容 -->
{block name="content"}
<!-- Custom Tabs -->
<div class="nav-tabs-custom">
	
	<ul class="nav nav-tabs">
		<li><a href="{:url('column/index')}">栏目列表</a></li>
		<li class="active"><a href="#tab_1" data-toggle="tab">编辑栏目</a></li>
		<li class="pull-right"><a href="#" class="text-muted" ><i class="fa fa-gear"></i></a></li>
	</ul>
	
	<div class="tab-content">
		<div class="tab-pane active" id="tab_1" style="max-width:800px;">
			 
				<form role="form" action="{:url('column/columnSave')}" id="form-add">
					<input type="hidden" name="id" value="{$info.id}"/>
					 
					<div class="form-group">
						<label>上级</label>
						<select class="form-control " name="pid" >
							<option value="0">顶级</option>
							{foreach $column as $v}
								<option value="{$v.id}" {eq name="info.pid" value="$v.id" }selected{/eq} >{$v.html}{$v.title}</option>
							{/foreach}
						</select>
					</div> 
					 
					<div class="form-group">
						<label for="title">名称</label>
						<input type="text" class="form-control" id="title" name="title" value="{$info.title}" autocomplete="off" placeholder="名称">
					</div>
					
					<div class="form-group">
						<label for="picture">封面图(支持:jpg、jpeg、png、gif)</label>
						<div id="img"></div>  
					</div>
					
					<div class="form-group">
						<label for="descript">描述</label>
						<textarea class="form-control" rows="3" name="descript">{$info.descript}</textarea>
					</div>
					  
					<div class="form-group">
						<label>
							<input type="radio" name="isShow" id="isShow1" value="1" class="flat-red" {eq name="info['isShow']" value="1" }checked{/eq}> 正常
						</label>
						<label>
							<input type="radio" name="isShow" id="isShow2" class="flat-red" value="0" {eq name="info['isShow']" value="0" }checked{/eq}> 禁用
						</label>
					</div>
					 
					
					<button class="btn btn-success" type="submit">保存</button>	 
				</form>
			 
		  
		</div><!-- /.tab-pane -->
 
	</div><!-- /.tab-content -->
</div><!-- nav-tabs-custom -->
 

{/block}

<!-- js -->
{block name="js"}
 	
	<script type="text/javascript">
		$(function () {
		 
		});
  
		//表单提交
    	$(document)
	    	.ajaxStart(function(){
	    		$("button:submit").addClass("btn-default").removeClass('btn-primary').attr("disabled", true);
	    	})
	    	.ajaxStop(function(){
	    		$("button:submit").removeClass("btn-default").addClass("btn-primary").attr("disabled", false);
	    	});

    	$("form").submit(function(){
			 
    		var self = $(this);
    		$.post(self.attr("action"), self.serialize(), success, "json");
    		return false;

    		function success(data){
    			if(data.status){
    				layer.msg(data.msg, {
						icon:1,
						offset: 0,
						shift: 0,
						time:1500
					},function(){
						//window.location.reload();//刷新当前页面 ;
					});
    			} else {
    				layer.msg(data.msg, {
						icon:0,
						offset: 0,
						shift: 6,
						time:1500
					}); 
    				 
    			}
    		}
    	});
	</script>
	<link rel="stylesheet"  href="{$Think.WWW_ROOT}/public/static/common/Huploadify/Huploadify.css" >
	<script charset="utf-8" src="{$Think.WWW_ROOT}/public/static/common/Huploadify/jquery.Huploadify.js"></script>
	<script charset="utf-8" src="{$Think.WWW_ROOT}/public/static/common/Huploadify/Huploadify.js"></script>
	<script>
	  $(function(){
		  var upUrl = "{:url('upimage')}";
		  var delUrl = "{:url('delimage')}";
		  var img = "{$info.img}";
		  upimage("img","img",upUrl,delUrl, img);
	   });
   </script>
{/block}